<template>
  <div>
    <a-card>{{ onlineInfo.chooser }}</a-card>
    <div v-if="chooserFlag == 2">
      <a-descriptions bordered :column="4">
        <a-descriptions-item label="solr collection名称" :span="2">
          {{ onlineInfo.indexName }}
        </a-descriptions-item>
        <a-descriptions-item label="分片数量" :span="2">
          {{ onlineInfo.amount }}
        </a-descriptions-item>
      </a-descriptions>
    </div>
    <div v-else>
      <a-descriptions bordered :column="4">
        <a-descriptions-item label="ES-Index名称" :span="2">
          {{ onlineInfo.indexName }}
        </a-descriptions-item>
        <a-descriptions-item label="分片数量" :span="2">
          {{ onlineInfo.amount }}
        </a-descriptions-item>
      </a-descriptions>
    </div>
    <a-table :columns="onlineColumn" :data-source="onlineInfo.indexColumnList">
      <a-checkbox slot="saveFlag" slot-scope="text" :defaultChecked="text" disabled></a-checkbox>
    </a-table>
  </div>
</template>

<script>
export default {
  name: 'onlineDeviceDescription',
  props: {
    onlineInfo: {
      type: Object
    }
  },
  computed: {
    chooserFlag() {
      if (this.onlineInfo.chooser == 'Hbase+Solr') {
        return 2
      } else if (this.onlineInfo.chooser == 'Hbase') {
        return 1
      } else if (this.onlineInfo.chooser == 'Hbase+ES') {
        return 3
      }
    }
  },
  data() {
    return {
      onlineColumn: [
        { title: '索引字段名', dataIndex: 'columnName' },
        { title: '索引字段类型', dataIndex: 'columnType' },
        { title: '索引值是否储存', dataIndex: 'saveFlag', scopedSlots: { customRender: 'saveFlag' } },
        { title: '字段用途', dataIndex: 'columnPurpose' }
      ]
    }
  }
}
</script>

<style scoped lang="less"></style>
